Skip to content

Security: Server-side XSS sink in Streamlit app (unsafe_allow_html=True) with model-controlled content#92

Open
tuanaiseo wants to merge 1 commit intodatalab-to:masterfrom
tuanaiseo:contribai/fix/security/server-side-xss-sink-in-streamlit-app-un
Open

Security: Server-side XSS sink in Streamlit app (unsafe_allow_html=True) with model-controlled content#92
tuanaiseo wants to merge 1 commit intodatalab-to:masterfrom
tuanaiseo:contribai/fix/security/server-side-xss-sink-in-streamlit-app-un

Conversation

@tuanaiseo
Copy link
Copy Markdown

Problem

The Streamlit UI renders OCR/model output using st.markdown(..., unsafe_allow_html=True). Model output is not sanitized and may contain arbitrary HTML/JS-like payloads if prompted or induced by crafted input documents. This can execute script in users' browsers when viewing OCR results.

Severity: high
File: chandra/scripts/app.py

Solution

Avoid unsafe_allow_html=True for untrusted content. If HTML rendering is required, sanitize output first using a strict allowlist sanitizer (e.g., Bleach) that removes scripts, event handlers, dangerous URLs (javascript:), and unsafe attributes/styles.

Changes

  • chandra/scripts/app.py (modified)

Testing

  • Existing tests pass
  • Manual review completed
  • No new warnings/errors introduced

The Streamlit UI renders OCR/model output using `st.markdown(..., unsafe_allow_html=True)`. Model output is not sanitized and may contain arbitrary HTML/JS-like payloads if prompted or induced by crafted input documents. This can execute script in users' browsers when viewing OCR results.

Affected files: app.py

Signed-off-by: tuanaiseo <221258316+tuanaiseo@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant